package main

import (
	"fmt"
	"time"
)

func do() {
	var now time.Time
	//for i := 0; i < 10; i++ {
	//	now = time.Now()
	//	time.Sleep(1 * time.Second)
	//	fmt.Println("time: ", now)
	//}
	timer := time.NewTimer(2 * time.Second)
	usage := 0
	// 使用timer
	go func() {
		for {
			// timer.Reset(2 * time.Second) // 这里是复位计时器
			now = time.Now()
			fmt.Println(now.Hour())
			select {
			case <-timer.C:
				if usage == 1000 {
					return
				}
				usage++
				fmt.Println("msg coming")
			}
		}
	}()
	getCh := make(chan int)
	go func() {
		for {
			select {
			case <-getCh:
				fmt.Println("向客户端发送通知")
			}
		}
	}()
	select {}
	//var tingting = make(chan int)
	//
	//func tingtingSend() {
	//	if time.Now().Hour() > 20 && time.Now().Hour() < 21 {
	//		tingting <- 1
	//	}
	//}
	// 设置定时后台协程进行数据截取
	//go func() {
	//	for time.Now().Minute() == 30 {
	//		tingtingSend()
	//	}
	//}()

	/*
		ctx := context.Background()
			conn, _, err := h2conn.Connect(ctx, "example.com")
			if err != nil {
				log.Fatalf("Failed to initiate connection: %v", err)
			}
			defer conn.Close()

			// 在这里添加你的通信逻辑，比如发送请求或接收响应。

			fmt.Println("Connection established.")
	*/

}
